package ints

import (
	"gitee.com/cjianwen/go/demo/socks_v2/raft_demo/server/proto"
	"gitee.com/cjianwen/go/demo/socks_v2/raft_demo/server/types"
)

type IRoleState interface {
	GetTerm() uint32
	IsFollower() bool
	IsCandidate() bool
	IsLeader() bool
	AddData(data string) uint32 // 返回id 值
}

type INodeConns interface {
	ConnCountIsOK() bool
	GetConnCount() int
	ConnSvrs()
	CloseConns()
	SendPackToAll(pack *proto.PackData) error
}

type IEntries interface {
	GetCommitIdx() uint32
	Commit(dataIdx uint32) error
	AppendEntries(data *types.EntryItem) uint32
	UpdateEntries(idx uint32, data *types.EntryItem) error
	GetEntryItem(idx uint32) *types.EntryItem
	GetIndex() uint32 // 获取数据长度，最大索引号
	GetEntryItemId(idx uint32) uint32
	GetEntryItemTerm(idx uint32) uint32
}
